package love.baby;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @create: 2022-03-01 10:37
 * @description:
 **/

public class MqConsumer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = MqBase.initChannel();
        DeliverCallback deliverCallback = (consumerTag,deliver) -> {
            String msg = new String(deliver.getBody());
            System.out.println("接收到消息："+msg);
        };
        CancelCallback cancelCallback = (c) -> {
            System.out.println("消息中断！");
        };
        channel.basicConsume(MqBase.QUEUE_NAME,true,deliverCallback,cancelCallback);
    }
}
